#!/usr/bin/env python
# -*- coding:utf-8 -*-

# file:exercise1.py
# author:wmf
# datetime:2021/4/16 21:47
# software: PyCharm
'''
this is function description
'''
# import module your need


# 请设计一个decorator，它可作用于任何函数上，并打印该函数的执行时间：


import time, functools


def metric(func):
    @functools.wraps(func)
    def get_time(*args, **kw):
        start_time = time.time()
        func(*args, **kw)
        end_time = time.time()
        print("运行时间为%s"%(end_time - start_time))
        return func(*args, **kw)
    return get_time


@metric
def fast(x, y):
    time.sleep(0.0012)
    return x + y;


@metric
def slow(x, y, z):
    time.sleep(0.1234)
    return x * y * z;


f = fast(11, 22)
s = slow(11, 22, 33)

if f != 33:
    print('测试失败!')
elif s != 7986:
    print('测试失败!')
